#include "TextChatMessagePainter.h"
#include "../../Message/TextChatMessage.h"
#include <QPainter>
#include <QDebug>

CTextChatMessagePainter::CTextChatMessagePainter(CTextChatMessage *pTextMessage)
    :m_pTextMessage(pTextMessage){

}

 QSize CTextChatMessagePainter::GetSize() const{
     if (nullptr == m_pTextMessage){
         QSize(0,0);
     }

     return m_pTextMessage->GetSize();
 }

void CTextChatMessagePainter::PainterContexnt(QPainter &painter){
    if (nullptr == m_pTextMessage){
        return;
    }

    QPen penText;
    penText.setColor(QColor(51,51,51));
    painter.setPen(penText);
    QTextOption option(Qt::AlignLeft );
    option.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
    const QRect rectFrame(75, 25 , GetSize().width(), GetSize().height());
    painter.drawText(rectFrame, m_pTextMessage->GetContext(),option);
    qDebug()<<m_pTextMessage->GetContext() << GetSize();
}
